'Imports System.Data.SqlClient
'Imports System.Configuration

'Friend Class MsSqlClient

'    Implements IDisposable
'    Private cn As SqlConnection
'    Dim Transa As SqlTransaction
'    Dim erro As Boolean = False

'    Dim motor As String
'    Dim ParamNombre()
'    Dim ParamTipo()
'    Dim ParamValor()

'    Public Function Conectar()
'        Try
'            cn.Open()
'            Transa = cn.BeginTransaction
'        Catch ex As Exception
'            erro = True
'            'Dim fp As IO.StreamWriter

'            'Try
'            '    fp = IO.File.CreateText("D:\Logs\log0.txt")
'            '    fp.WriteLine(ex.Message)
'            '    '& " " & vbCrLf & " " & ex.Message.ToString)
'            '    fp.Close()
'            'Catch ex2 As Exception

'            'End Try
'        End Try

'    End Function

'    Sub New(Optional ByVal connectionstring As String = "")
'        If connectionstring = "" Then
'            Dim MyAppSettingsReader As New AppSettingsReader
'            connectionstring = MyAppSettingsReader.GetValue("ConnectionString", GetType(String))
'        End If
'        cn = New SqlConnection
'        Transa = DirectCast(Transa, SqlTransaction)

'        If Not cn Is Nothing Then
'            If cn.State <> ConnectionState.Closed Then
'                Exit Sub
'            End If
'        End If
'        cn = New SqlConnection
'        cn.ConnectionString = connectionstring
'        Conectar()
'    End Sub

'    'Metodo Para Paginar 
'    Public Function Executedataset(ByRef Rp As BCSNetResponse.MsSqlClient, ByVal Csql As String, ByRef Obj() As Object)
'        Dim dr As SqlDataReader
'        Try
'            Dim paginacion As Integer = Obj(Obj.Length - 1)
'            Dim Pagina As Integer = Obj(Obj.Length - 2)
'            Dim dt As New DataTable
'            dt.TableName = "nodos"

'            Dim Row As DataRow
'            Dim cell As New DataColumn
'            dr = SqlClientHelper.ExecuteReader(Transa, CommandType.Text, Csql)
'            Dim i As Integer
'            For i = 0 To dr.FieldCount - 1
'                dt.Columns.Add(dr.GetName(i))
'            Next
'            Dim ct As Integer = 1, pag As Integer = 0
'            Do While dr.Read
'                pag = pag + 1
'                If ((paginacion * Pagina) - paginacion) + 1 <= pag And (paginacion * Pagina) >= pag Then
'                    Row = dt.NewRow
'                    For i = 0 To dr.FieldCount - 1
'                        Row(i) = dr.GetValue(i)
'                    Next
'                    Rp.TieneDatos = True
'                    dt.Rows.Add(Row)
'                End If
'            Loop
'            Rp.Ds.Tables.Add(dt)
'            dr.Close()

'        Catch ex As Exception
'            Rp.TieneDatos = False
'            Rp.Errores = True
'            Rp.MensajeError = ex.Message
'            dr.Close()
'        End Try

'    End Function
'    Public Sub ExecuteNonQuery(ByRef Rp As BCSNetResponse.MsSqlClient, ByVal Csql As String)
'        Try
'            SqlClientHelper.ExecuteNonquery(Transa, Csql)
'        Catch ex As Exception
'            erro = True
'            Rp.TieneDatos = False
'            Rp.Errores = True
'            Rp.MensajeError = ex.Message

'        End Try

'    End Sub
'    Public Sub ExecuteNonquery(ByRef Rp As BCSNetResponse.MsSqlClient)

'        Try
'            SqlClientHelper.ExecuteNonquery(Transa, Rp.StoredProcedure, False, Rp.Parametro)
'        Catch ex As Exception
'            erro = True
'            Rp.TieneDatos = False
'            Rp.Errores = True
'            Rp.MensajeError = ex.Message
'        End Try
'    End Sub

'    Public Sub ExecuteScalar(ByRef Rp As BCSNetResponse.MsSqlClient, ByVal Csql As String)
'        Try
'            Rp.GetScalar = SqlClientHelper.ExecuteScalar(Transa, Csql)
'            Rp.TieneDatos = True

'        Catch ex As Exception
'            erro = True
'            Rp.TieneDatos = False
'            Rp.Errores = True
'            Rp.MensajeError = ex.Message
'        End Try

'    End Sub
'    Public Sub ExecuteScalar(ByRef Rp As BCSNetResponse.MsSqlClient)
'        Try
'            Rp.GetScalar = SqlClientHelper.ExecuteScalar(Transa, Rp.StoredProcedure, Rp.Parametro)

'        Catch ex As Exception
'            Rp.TieneDatos = False
'            Rp.Errores = True
'            Rp.MensajeError = ex.Message
'        End Try
'    End Sub

'    Public Sub ExecuteDataTable(ByRef Rp As BCSNetResponse.MsSqlClient, ByVal Csql As String)
'        Try
'            Rp.DtTable = SqlClientHelper.ExecuteDataset(Transa, Csql).Tables(0)
'        Catch ex As Exception
'            erro = True
'            Rp.TieneDatos = False
'            Rp.Errores = True
'            erro = True
'            Rp.MensajeError = ex.Message
'        End Try
'    End Sub
'    'Public Sub ExecuteNonqueryIdentity(ByRef Rp As NetResponse.MsSql)
'    '    Try
'    '        Rp.DtTable = SqlClient.ExecuteDataset(Transa, Rp.StoredProcedure, Rp.Parametro).Tables(0)
'    '    Catch ex As Exception
'    '        erro = True
'    '        Rp.TieneDatos = False
'    '        Rp.Errores = True
'    '        erro = True
'    '        Rp.MensajeError = ex.Message
'    '    End Try
'    'End Sub
'    Public Sub ExecuteDataTable(ByRef Rp As BCSNetResponse.MsSqlClient)
'        Try
'            Rp.DtTable = SqlClientHelper.ExecuteDataset(Transa, Rp.StoredProcedure, Rp.Parametro).Tables(0)
'        Catch ex As Exception
'            erro = True
'            Rp.TieneDatos = False
'            Rp.Errores = True
'            erro = True
'            Rp.MensajeError = ex.Message
'        End Try
'    End Sub
'    Public Sub ExecuteDataset(ByRef Rp As BCSNetResponse.MsSqlClient, ByVal Csql As String)
'        Try
'            Rp.Ds = SqlClientHelper.ExecuteDataset(Transa, Csql)
'        Catch ex As Exception
'            erro = True
'            Rp.TieneDatos = False
'            Rp.Errores = True
'            erro = True
'            Rp.MensajeError = ex.Message
'        End Try
'    End Sub
'    Public Sub ExecuteDataset(ByRef Rp As BCSNetResponse.MsSqlClient)
'        Try
'            Rp.Ds = SqlClientHelper.ExecuteDataset(Transa, Rp.StoredProcedure, Rp.Parametro)
'        Catch ex As Exception
'            erro = True
'            Rp.TieneDatos = False
'            Rp.Errores = True
'            Rp.MensajeError = ex.Message
'        End Try
'    End Sub


'    Public Sub ExecuteReader(ByRef Rp As BCSNetResponse.MsSqlClient, ByVal Csql As String)
'        Try
'            Rp.GetDataReader = SqlClientHelper.ExecuteReader(Transa, Csql)
'        Catch ex As Exception
'            erro = True
'            Rp.TieneDatos = False
'            Rp.Errores = True
'            Rp.MensajeError = ex.Message
'        End Try
'    End Sub
'    Public Sub ExecuteReader(ByRef Rp As BCSNetResponse.MsSqlClient)
'        Try
'            Rp.GetDataReader = SqlClientHelper.ExecuteReader(Transa, Rp.StoredProcedure, Rp.Parametro)
'            Rp.TieneDatos = True

'        Catch ex As Exception
'            erro = True
'            Rp.TieneDatos = False
'            Rp.Errores = True
'            Rp.MensajeError = ex.Message
'        End Try
'    End Sub
'    Public Sub InsertUpdateInto(ByRef errdesc As String, ByVal csql As String)
'        Try
'            SqlClientHelper.ExecuteNonquery(Transa, csql)
'        Catch ex As Exception
'            erro = True
'            errdesc = ex.Message
'        End Try
'    End Sub


'    Public Sub Commit()
'        If erro = True Then
'            Try
'                Transa.Rollback()
'                Close()
'            Catch ex As Exception
'            End Try
'            Exit Sub
'        End If
'        If Not cn.State = ConnectionState.Open Then
'            Exit Sub
'        End If
'        Transa.Commit()
'    End Sub
'    Public Sub Close()
'        cn.Close()
'    End Sub
'    Private disposedValue As Boolean = False  ' To detect redundant calls
'    Protected Overridable Sub Dispose(ByVal disposing As Boolean)
'        If Not Me.disposedValue Then
'            If disposing Then
'                'TODO:              free unmanaged resources when explicitly called
'            End If

'            'TODO: free shared unmanaged resources
'        End If
'        Me.disposedValue = True
'    End Sub

'#Region " IDisposable Support "
'    ' This code added by Visual Basic to correctly implement the disposable pattern.
'    Public Sub Dispose() Implements IDisposable.Dispose
'        ' Do not change this code.  Put cleanup code in Dispose(ByVal disposing As Boolean) above.
'        Close()
'        Dispose(True)
'        GC.SuppressFinalize(Me)
'        GC.Collect()
'    End Sub
'#End Region

'End Class
